﻿<%@ Page Title="" Language="C#" MasterPageFile="~/TsSite.Master" AutoEventWireup="true" CodeBehind="ServiceCarScheduleList.aspx.cs" Inherits="TireService.Web.Casehandling.ServiceCarScheduleList" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxSplitter" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1.Export, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script src="../Scripts/ModalPopup.js" type="text/javascript"></script>
    
    <dx:ASPxRoundPanel ID="rpContent" runat="server" Width="100%" ShowHeader="true" Height="100%">
        <PanelCollection>
            <dx:PanelContent ID="PanelContent1" runat="server">
                
                <asp:UpdatePanel ID="upMessage" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <table border="0" cellspacing="0" cellpadding="5">
                            <tr>
                                <td>
                                    <div style="font-family: Tahoma; font-size: 9pt; font-weight: normal; color: #f15e34">
                                        &nbsp;<asp:Literal ID="lMessage" runat="server"></asp:Literal>
                                    </div>
                                </td>
                            </tr>
                        </table>          
                    </ContentTemplate>
                </asp:UpdatePanel>
                
                <asp:UpdatePanel ID="upServiceCarSchedule" runat="server">
                    <ContentTemplate>
                        
                        <!-- Javascript for Google map and streetview Modal popup view -->
                        <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
                        <script type="text/javascript">

                            function initialize(latitude, longitude) {
                                var fenway = new google.maps.LatLng(latitude, longitude);
                                var mapOptions = {
                                    center: fenway,
                                    zoom: 14,
                                    mapTypeId: google.maps.MapTypeId.ROADMAP
                                };
                                var map = new google.maps.Map(
                                document.getElementById("map_canvas"), mapOptions);
                                var panoramaOptions = {
                                    position: fenway,
                                    pov: {
                                        heading: 34,
                                        pitch: 10,
                                        zoom: 1
                                    }
                                };
                                var panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"), panoramaOptions);
                                map.setStreetView(panorama);

                                launchGoogleStreetView = true;
                            }
                        </script>

                        <!-- Javascript for Modal popup forms -->
                        <script type="text/javascript">
                            var launchPlanningSheet = false;
                            var launchPackagingList = false;
                            var launchEditTime = false;
                            var launchEditNote = false;
                            var launchGoogleStreetView = false;

                            function resetEditTimeScheduleModal() {
                                // set the "launch" flag to true (set by calling RegisterStartupScript in c#)
                                launchEditTime = false;
                            }

                            function resetEditNoteModal() {
                                // set the "launch" flag to true (set by calling RegisterStartupScript in c#)
                                launchEditNote = false;
                            }

                            function resetGoogleStreetViewModal() {
                                // set the "launch" flag to true (set by calling RegisterStartupScript in c#)
                                launchGoogleStreetView = false;
                            }

                            function launchEditTimeScheduleModal() {
                                // set the "launch" flag to true (set by calling RegisterStartupScript in c#)
                                launchEditTime = true;
                            }

                            function launchEditNoteModal() {
                                // set the "launch" flag to true (set by calling RegisterStartupScript in c#)
                                launchEditNote = true;
                            }

                            function launchGoogleStreetViewModal() {
                                // set the "launch" flag to true (set by calling RegisterStartupScript in c#)
                                launchGoogleStreetView = true;
                            }

                            function launchPlanningSheetWindow() {
                                // set the "launch" flag to true (set by calling RegisterStartupScript in c#)
                                launchPlanningSheet = true;
                            }

                            function pageLoad() {
                                if (launchEditTime) {
                                    // Show the dialog box only if "launch = true"
                                    // This must be done in page load because the RegisterStartupScript happened before page load
                                    pcEditTimeSchedule.Show();
                                }
                                if (launchEditNote) {
                                    // Show the dialog box only if "launch = true"
                                    // This must be done in page load because the RegisterStartupScript happened before page load
                                    pcEditNote.Show();
                                }
                                if (launchGoogleStreetView) {
                                    // Show the dialog box only if "launch = true"
                                    // This must be done in page load because the RegisterStartupScript happened before page load
                                    pcGoogleStreetView.Show();
                                }
                                if (launchPlanningSheet) {
                                    // Show the dialog box only if "launch = true"
                                    // This must be done in page load because the RegisterStartupScript happened before page load
                                    // TODO: WRITE REAL CODE
                                    window.open("www.google.dk", "Planlægningsskema");
                                    launchPlanningSheet = false;
                                }
                                if (launchPackagingList) {
                                    // Show the dialog box only if "launch = true"
                                    // This must be done in page load because the RegisterStartupScript happened before page load
                                    // TODO: WRITE CODE
                                    launchPackagingList = false;
                                }
                            }
                        </script>

                        <!-- Start: Modal popup windows -->
                        <asp:HiddenField ID="hfServiceCarScheduleDetailId" runat="server" />


                        <!-- Edit timeschedule: Start/End -->
                        <dx:ASPxPopupControl ID="pcEditTimeSchedule" runat="server" CloseAction="CloseButton" Modal="True"
                            PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pcEditTimeSchedule"
                            HeaderText="Rediger tidsinterval" AllowDragging="False" EnableAnimation="False" EnableViewState="False">
                            <ClientSideEvents Closing="function(s, e) { resetEditTimeScheduleModal(); }" />
                            <ContentCollection>
                                <dx:PopupControlContentControl runat="server">
                                    <dx:ASPxPanel ID="Panel1" runat="server" DefaultButton="btOK">
                                        <PanelCollection>
                                            <dx:PanelContent runat="server">
                                                <table width="350px">
                                                    <tr>
                                                        <td>Start</td>
                                                        <td>
                                                            <asp:TextBox ID="txtStartHour" runat="server" Width="25px"></asp:TextBox>:<asp:TextBox ID="txtStartMinut" runat="server" Width="25px"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>Slut</td>
                                                        <td>
                                                            <asp:TextBox ID="txtEndHour" runat="server" Width="25px"></asp:TextBox>:<asp:TextBox ID="txtEndMinut" runat="server" Width="25px"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2">
                                                            <dxe:ASPxButton ID="btnEditTimeSchedule" runat="server" ClientIDMode="AutoID" OnClick="btnEditTimeSchedule_Click" Text="Gem">
                                                                <ClientSideEvents Click="function(s, e) { pcEditTimeSchedule.Hide(); }" />
                                                            </dxe:ASPxButton>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </dx:PanelContent>
                                        </PanelCollection>
                                    </dx:ASPxPanel>
                                </dx:PopupControlContentControl>
                            </ContentCollection>
                        </dx:ASPxPopupControl>

                        <!-- Edit note on scheduledetail -->
                        <dx:ASPxPopupControl ID="pcEditNote" runat="server" CloseAction="CloseButton" Modal="True"
                            PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pcEditNote"
                            HeaderText="Rediger note" AllowDragging="False" EnableAnimation="False" EnableViewState="False">
                            <ClientSideEvents Closing="function(s, e) { resetEditNoteModal(); }" />
                            <ContentCollection>
                                <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
                                    <dx:ASPxPanel ID="ASPxPanel1" runat="server" DefaultButton="btOK">
                                        <PanelCollection>
                                            <dx:PanelContent ID="PanelContent2" runat="server">
                                                <table width="350px">
                                                    <tr>
                                                        <td>Note</td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <asp:TextBox ID="txtNote" runat="server" Width="200px" Height="200px"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2">
                                                            <dxe:ASPxButton ID="btnEditNote" runat="server" ClientIDMode="AutoID" OnClick="btnEditNote_Click" Text="Gem">
                                                                <ClientSideEvents Click="function(s, e) { pcEditNote.Hide(); }" />
                                                            </dxe:ASPxButton>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </dx:PanelContent>
                                        </PanelCollection>
                                    </dx:ASPxPanel>
                                </dx:PopupControlContentControl>
                            </ContentCollection>
                        </dx:ASPxPopupControl>

                        <!-- Show google map and streetview -->
                        <dx:ASPxPopupControl ID="pcGoogleStreetView" runat="server" CloseAction="CloseButton" Modal="True" Width="620px" Height="320px"
                            PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" ClientInstanceName="pcGoogleStreetView"
                            HeaderText="Google map og streetview" AllowDragging="False" EnableAnimation="False" EnableViewState="False">
                            <ClientSideEvents Closing="function(s, e) { resetGoogleStreetViewModal(); }" />
                            <ContentCollection>
                                <dx:PopupControlContentControl ID="PopupControlContentControl2" runat="server">
                                    <dx:ASPxPanel ID="ASPxPanel2" runat="server" DefaultButton="btOK">
                                        <PanelCollection>
                                            <dx:PanelContent ID="PanelContent3" runat="server">
                                                <table width="610px" border="0" cellspacing="5px" cellpadding="0px">
                                                    <tr>
                                                        <td>
                                                            <div id="map_canvas" style="width: 300px; height: 300px"></div>
                                                        </td>
                                                        <td>
                                                            <div id="pano" style="width: 300px; height: 300px;"></div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </dx:PanelContent>
                                        </PanelCollection>
                                    </dx:ASPxPanel>
                                </dx:PopupControlContentControl>
                            </ContentCollection>
                        </dx:ASPxPopupControl>


                        <dx:ASPxSplitter ID="splitterServiceCarSchedule" ClientInstanceName="splitterServiceCarSchedule" runat="server" Height="600px" Width="100%">
                            <Styles>
                                <Pane>
                                    <Paddings Padding="0px" />
                                </Pane>
                            </Styles> 
                            <Panes>
                                <dx:SplitterPane MinSize="450px" Name="spScheduleSettings" ShowCollapseForwardButton="True">
                                    <Panes>
                                        <dx:SplitterPane Name="spCarForSchedule" ShowCollapseForwardButton="True">
                                            <ContentCollection>
                                                <dx:SplitterContentControl ID="SplitterContentControl4" runat="server">
                                                    <!-- Gridview with cars that need service/tire change -->
                                                    <dxwgv:ASPxGridView ID="gvCarNeedService" runat="server" 
                                                        Caption="Biler afventende hjulskift service" 
                                                        ClientInstanceName="gvCarNeedService" Width="100%"
                                                        KeyFieldName="TireSetId" AutoGenerateColumns="False" EnableCallBacks="False" 
                                                        oncustomunboundcolumndata="gvCarNeedService_CustomUnboundColumnData" 
                                                        OnFocusedRowChanged="gvCarNeedService_FocusedRowChanged"
                                                        oncustombuttoncallback="gvCarNeedService_CustomButtonCallback">
                                                        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                                                        <Border BorderWidth="0px" />
                                                        <Settings ShowVerticalScrollBar="true" ShowHeaderFilterButton="False" ShowGroupPanel="false" ShowFilterRow="False" />
                                                        <SettingsPager AlwaysShowPager="False" PageSize="20" Position="Bottom">
                                                            <Summary 
                                                                AllPagesText="Sider: {0} - {1} ({2} biler)" 
                                                                Text="Side {0} af {1} ({2} biler)" />
                                                        </SettingsPager>
                                                        <SettingsBehavior ProcessFocusedRowChangedOnServer="true" AllowFocusedRow="true" ConfirmDelete="True" AllowGroup="true" AllowDragDrop="false" />
                                                        <Columns>
                                                            <dxwgv:GridViewDataColumn FieldName="CarId" Visible="false" VisibleIndex="4" Caption="CarId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="CustomerId" Visible="false" VisibleIndex="4" Caption="CustomerId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="SubscriptionId" Visible="false" VisibleIndex="4" Caption="SubscriptionId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="TireSetId" Visible="false" VisibleIndex="4" Caption="TireSetId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ContainerId" Visible="false" VisibleIndex="4" Caption="ContainerId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="Address" Visible="false" VisibleIndex="4" Caption="Address">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ZipCode" Visible="false" VisibleIndex="4" Caption="ZipCode">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="City" Visible="false" VisibleIndex="4" Caption="City">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="CountryId" Visible="false" VisibleIndex="4" Caption="CountryId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="Longitude" Visible="false" VisibleIndex="4" Caption="Longitude">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="Latitude" Visible="false" VisibleIndex="4" Caption="Latitude">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="LongitudePrimary" Visible="false" VisibleIndex="4" Caption="LongitudePrimary">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="LatitudePrimary" Visible="false" VisibleIndex="4" Caption="LatitudePrimary">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="LongitudeSecondary" Visible="false" VisibleIndex="4" Caption="LongitudeSecondary">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="LatitudeSecondary" Visible="false" VisibleIndex="4" Caption="LatitudeSecondary">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="ContainerNumber" VisibleIndex="5" Caption="Lager">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="CarBrandDescription" VisibleIndex="6" Caption="Bilmærke">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="Model" VisibleIndex="7" Caption="Model">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="8" Caption="Reg.nr.">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="PrimaryAddress" VisibleIndex="9" Caption="Adresse">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="PrimaryCity" VisibleIndex="10" Caption="By">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="CustomerCountryId" VisibleIndex="10" Caption="CustomerCountryId" Visible="false">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="PrimaryZipCode" VisibleIndex="10" Caption="PrimaryZipCode" Visible="false">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="SecondaryAddress" VisibleIndex="9" Caption="SecondaryAddress" Visible="false">
                                                            </dxwgv:GridViewDataColumn>          
                                                            <dxwgv:GridViewDataColumn FieldName="SecondaryCity" VisibleIndex="10" Caption="SecondaryCity" Visible="false">
                                                            </dxwgv:GridViewDataColumn>          
                                                            <dxwgv:GridViewDataColumn FieldName="SecondaryZipCode" VisibleIndex="10" Caption="SecondaryZipCode" Visible="false">
                                                            </dxwgv:GridViewDataColumn>          
                                                            <dxwgv:GridViewDataColumn FieldName="Distance" VisibleIndex="11" Caption="Km pri." ToolTip="Afstand fra lager til kundens primære adresse">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="DistanceSecondary" VisibleIndex="11" Caption="Km sek." ToolTip="Afstand fra lager til kundens sekundære adresse">
                                                            </dxwgv:GridViewDataColumn>
                                                        </Columns>                                            
                                                    </dxwgv:ASPxGridView>
                                                </dx:SplitterContentControl>
                                            </ContentCollection>
                                        </dx:SplitterPane>
                                        <dx:SplitterPane Name="spNearbySchedules" ShowCollapseForwardButton="True">
                                            <ContentCollection>
                                                <dx:SplitterContentControl ID="SplitterContentControl2" runat="server">
                                                    <!-- Gridview with planned service from selected container -->
                                                    <dxwgv:ASPxGridView ID="gvPlannedServiceSchedule" runat="server" Caption="Planlagte hjulskift" ClientInstanceName="gvPlannedServiceSchedule" Width="100%"
                                                        KeyFieldName="ServiceCarScheduleDetailId" AutoGenerateColumns="False" EnableCallBacks="False" 
                                                        oncustomunboundcolumndata="gvPlannedServiceSchedule_CustomUnboundColumnData" Visible="false"
                                                        oncustombuttoncallback="gvPlannedServiceSchedule_CustomButtonCallback">
                                                        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                                                        <Border BorderWidth="0px" />
                                                        <Settings ShowGroupFooter="VisibleIfExpanded" ShowVerticalScrollBar="true" ShowHeaderFilterButton="False" ShowGroupPanel="false" ShowFilterRow="False" />
                                                        <SettingsPager AlwaysShowPager="false" PageSize="20" Position="Bottom">
                                                            <Summary 
                                                                AllPagesText="Sider: {0} - {1} ({2} hjulskift)" 
                                                                Text="Side {0} af {1} ({2} hjulskift)" />
                                                        </SettingsPager>
                                                        <SettingsBehavior AllowFocusedRow="false" ConfirmDelete="True" AllowGroup="true" AllowDragDrop="false" />
                                                        <Columns>
                                                            <dxwgv:GridViewCommandColumn VisibleIndex="1">
                                                                <CustomButtons>
                                                                    <dxwgv:GridViewCommandColumnCustomButton Text="Indsæt før" ID="InsertBefore" />
                                                                    <dxwgv:GridViewCommandColumnCustomButton Text="Indsæt efter" ID="InsertAfter" />
                                                                </CustomButtons>
                                                            </dxwgv:GridViewCommandColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="SequenceNumber" Visible="false" VisibleIndex="4" Caption="SequenceNumber">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ServiceCarScheduleId" Visible="false" VisibleIndex="4" Caption="ServiceCarScheduleId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ServiceCarScheduleDetailId" Visible="false" VisibleIndex="4" Caption="ServiceCarScheduleDetailId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="CarId" Visible="false" VisibleIndex="4" Caption="CarId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="CustomerId" Visible="false" VisibleIndex="4" Caption="CustomerId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ContainerId" Visible="false" VisibleIndex="4" Caption="ContainerId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ToLongitude" Visible="false" VisibleIndex="4" Caption="ToLongitude">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ToLatitude" Visible="false" VisibleIndex="4" Caption="ToLatitude">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="ContainerNumber" VisibleIndex="5" Caption="Lager">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="ScheduleDate" VisibleIndex="6" Caption="Dato">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="CarBrandDescription" VisibleIndex="6" Caption="Bilmærke">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="Model" VisibleIndex="7" Caption="Model">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="StartTime" VisibleIndex="8" Caption="Start">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="EndTime" VisibleIndex="9" Caption="Slut">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="DrivingDistance" VisibleIndex="10" Caption="Kørsel (km)">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="EstimatedDrivingTime" VisibleIndex="11" Caption="Kørselstid">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="SumEstimatedTime" UnboundType="String" VisibleIndex="12" Caption="Servicetid">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="TotalTime" UnboundType="String" VisibleIndex="13" Caption="Totaltid">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="DistancePrimary" UnboundType="String" VisibleIndex="14" Caption="Afstand primær" ToolTip="Afstand fra valgt bil's primære adresse til denne bil.">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="DistanceSecondary" UnboundType="String" VisibleIndex="15" Caption="Afstand sekundær" ToolTip="Afstand fra valgt bil's sekundære adresse til denne bil.">
                                                            </dxwgv:GridViewDataColumn>
                                                        </Columns>
                                                        <GroupSummary>
                                                            <dxwgv:ASPxSummaryItem FieldName="EstimatedDrivingTime" ShowInGroupFooterColumn="EstimatedDrivingTime" SummaryType="Sum" />
                                                            <dxwgv:ASPxSummaryItem FieldName="SumEstimatedTime" ShowInGroupFooterColumn="SumEstimatedTime" SummaryType="Sum" />
                                                            <dxwgv:ASPxSummaryItem FieldName="TotalTime" ShowInGroupFooterColumn="TotalTime" SummaryType="Sum" />
                                                        </GroupSummary>
                                                    </dxwgv:ASPxGridView>
                                            
                                                    <!-- Show nearby cars that needs service -->
                                                    <dxwgv:ASPxGridView ID="gvNearestCarNeedService" runat="server" 
                                                        Caption="Nærmeste biler der skal have skiftet hjul" 
                                                        ClientInstanceName="gvNearestCarNeedService" Width="100%" Visible="false"
                                                        KeyFieldName="TireSetId" AutoGenerateColumns="False" EnableCallBacks="False" 
                                                        oncustomunboundcolumndata="gvNearestCarNeedService_CustomUnboundColumnData"
                                                        oncustombuttoncallback="gvNearestCarNeedService_CustomButtonCallback">
                                                        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                                                        <Border BorderWidth="0px" />
                                                        <Settings ShowVerticalScrollBar="true" ShowHeaderFilterButton="False" ShowGroupPanel="false" ShowFilterRow="False" />
                                                        <SettingsPager AlwaysShowPager="False" PageSize="20" Position="Bottom">
                                                            <Summary 
                                                                AllPagesText="Sider: {0} - {1} ({2} biler)" 
                                                                Text="Side {0} af {1} ({2} biler)" />
                                                        </SettingsPager>
                                                        <SettingsBehavior AllowFocusedRow="false" ConfirmDelete="True" AllowGroup="true" AllowDragDrop="false" />
                                                        <Columns>
                                                            <dxwgv:GridViewCommandColumn VisibleIndex="1">
                                                                <CustomButtons>
                                                                    <dxwgv:GridViewCommandColumnCustomButton Text="Indsæt før" ID="CarNeedServiceInsertBefore" />
                                                                    <dxwgv:GridViewCommandColumnCustomButton Text="Indsæt efter" ID="CarNeedServiceInsertAfter" />
                                                                </CustomButtons>
                                                            </dxwgv:GridViewCommandColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="CarId" Visible="false" VisibleIndex="4" Caption="CarId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="CustomerId" Visible="false" VisibleIndex="4" Caption="CustomerId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="TireSetId" Visible="false" VisibleIndex="4" Caption="TireSetId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="SubscriptionId" Visible="false" VisibleIndex="4" Caption="SubscriptionId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ContainerId" Visible="false" VisibleIndex="4" Caption="ContainerId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="SequenceNumber" Visible="false" VisibleIndex="4" Caption="SequenceNumber">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="CustomerCountryId" Visible="false" VisibleIndex="4" Caption="CustomerCountryId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="LongitudePrimary" Visible="false" VisibleIndex="4" Caption="LongitudePrimary">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="LatitudePrimary" Visible="false" VisibleIndex="4" Caption="LatitudePrimary">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="LongitudeSecondary" Visible="false" VisibleIndex="4" Caption="LongitudeSecondary">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="LatitudeSecondary" Visible="false" VisibleIndex="4" Caption="LatitudeSecondary">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="ContainerNumber" VisibleIndex="5" Caption="Lager">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="CarBrandDescription" VisibleIndex="6" Caption="Bilmærke">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="Model" VisibleIndex="7" Caption="Model">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="8" Caption="Reg.nr.">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="PrimaryAddress" VisibleIndex="9" Caption="Adresse">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="PrimaryCity" VisibleIndex="10" Caption="By">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="PrimaryZipCode" VisibleIndex="10" Caption="PrimaryZipCode" Visible="false">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="SecondaryAddress" VisibleIndex="9" Caption="SecondaryAddress" Visible="false">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="SecondaryCity" VisibleIndex="10" Caption="SecondaryCity" Visible="false">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="SecondaryZipCode" VisibleIndex="10" Caption="SecondaryZipCode" Visible="false">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="DistanceToCarPrimary" UnboundType="String" VisibleIndex="11" Caption="Km pri." ToolTip="Afstand fra bil til kundens primære adresse">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="DistanceToCarSecondary" UnboundType="String" VisibleIndex="11" Caption="Km sek." ToolTip="Afstand fra bil til kundens sekundære adresse">
                                                            </dxwgv:GridViewDataColumn>
                                                        </Columns>                                            
                                                    </dxwgv:ASPxGridView>
                                                </dx:SplitterContentControl>
                                            </ContentCollection>
                                        </dx:SplitterPane>
                                    </Panes>
                                    <ContentCollection>
                                        <dx:SplitterContentControl runat="server" SupportsDisabledAttribute="True">
                                        </dx:SplitterContentControl>
                                    </ContentCollection>
                                </dx:SplitterPane>
                                <dx:SplitterPane MinSize="400px">
                                    <Panes>
                                        <dx:SplitterPane Name="spScheduleDetails">
                                            <ContentCollection>
                                                <dx:SplitterContentControl ID="SplitterContentControl5" runat="server">
                                                    <table width="100">
                                                        <tr>
                                                            <td valign="top">
                                                                <table>
                                                                    <tr>
                                                                        <td>Medarbejder</td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <dxe:ASPxComboBox ID="ddlEmployee" TextFormatString="{0} - {1} {2}" ValueType="System.String" runat="server" ValueField="EmployeeId" TextField="Name" DropDownStyle="DropDownList" IncrementalFilteringMode="StartsWith" OnSelectedIndexChanged="ddlEmployee_SelectedIndexChanged" AutoPostBack="true">
                                                                                 <Columns>
                                                                                    <dxe:ListBoxColumn FieldName="Name" />
                                                                                    <dxe:ListBoxColumn FieldName="ZipCode" />
                                                                                    <dxe:ListBoxColumn FieldName="City" />
                                                                                </Columns>
                                                                            </dxe:ASPxComboBox>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>Servicebil</td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <dxe:ASPxComboBox ID="ddlServiceCar" runat="server" ClientIDMode="AutoID" ValueField="ServiceCarId" TextField="Description" DropDownStyle="DropDownList" IncrementalFilteringMode="StartsWith" 
                                                                                ValueType="System.String" AutoPostBack="true" TextFormatString="{0} - {1} {2}"
                                                                                OnSelectedIndexChanged="ddlServiceCar_SelectedIndexChanged">
                                                                                <Columns>
                                                                                    <dxe:ListBoxColumn FieldName="Description" />
                                                                                    <dxe:ListBoxColumn FieldName="ZipCode" />
                                                                                    <dxe:ListBoxColumn FieldName="City" />
                                                                                </Columns>
                                                                            </dxe:ASPxComboBox>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Button ID="btnCreateServiceCarSchedule" runat="server" Text="Opret" OnClick="btnCreateServiceCarSchedule_Click" />
                                                                            <dxe:ASPxCheckBox ID="cbUserCarSecondaryAddress" runat="server" Text="Brug sekundær adresse">
                                                                            </dxe:ASPxCheckBox>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <hr />
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <dxe:ASPxComboBox ID="ddlAction" runat="server">
                                                                                <Items>
                                                                                    <dxe:ListEditItem Value="0" Selected="true" Text="-- Vælg handling --" />
                                                                                    <%--<dxe:ListEditItem Value="1" Text="Vis kørselsskema" />
                                                                                    <dxe:ListEditItem Value="2" Text="Vis pakkeseddel" />--%>
                                                                                    <dxe:ListEditItem Value="3" Text="Send godkendelse email til valgt" />
                                                                                    <dxe:ListEditItem Value="4" Text="Send godkendelse email til alle" />
                                                                                    <dxe:ListEditItem Value="5" Text="Angiv kunde godkendelse" />
                                                                                    <dxe:ListEditItem Value="6" Text="Fjern kunde godkendelse" />
                                                                                    <dxe:ListEditItem Value="7" Text="Rediger start/slut tid" />
                                                                                    <dxe:ListEditItem Value="8" Text="Tilføj/rediger note" />
                                                                                    <dxe:ListEditItem Value="9" Text="Google map/streetview" />
                                                                                    <dxe:ListEditItem Value="10" Text="Skift til primær/sekundær adresse" />
                                                                                    <dxe:ListEditItem Value="11" Text="Skift til valgfri adresse" />
                                                                                </Items>
                                                                            </dxe:ASPxComboBox>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>
                                                                            <asp:Button ID="btnRunAction" runat="server" Text="Udfør" OnClick="btnRunAction_Click" />
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                            <td valign="top">
                                                                <dxe:ASPxCalendar ID="calScheduleDate" runat="server" AutoPostBack="true" 
                                                                    OnDayRender="calScheduleDate_DayRender" 
                                                                    OnSelectionChanged="calScheduleDate_SelectionChanged">
                                                                </dxe:ASPxCalendar>
                                                            </td>
                                                            <%--<td valign="top">
                                                                
                                                                <asp:LinkButton ID="lbtnFindNextServiceCarSchedule" runat="server" 
                                                                    OnClick="lbtnFindNextServiceCarSchedule_Click">Find næste planlagte service</asp:LinkButton><br />
                                                                <asp:HyperLink ID="hlShowServiceCarSchedule" runat="server" Target="_blank">Vis kørselsskema</asp:HyperLink><br />
                                                                <asp:HyperLink ID="hlShowPackagingSchedule" runat="server" Target="_blank">Vis pakkeseddel</asp:HyperLink><br />
                                                                <asp:LinkButton ID="lbtnSendCustomerEmailConfirmation" runat="server" OnClick="lbtnSendCustomerEmailConfirmation_Click">Send bekræftelses email til kunder</asp:LinkButton><br />
                                                                <ajaxToolkit:ConfirmButtonExtender ID="cbeSendCustomerEmailConfirmation" runat="server"
                                                                    TargetControlID="lbtnSendCustomerEmailConfirmation"
                                                                    ConfirmText="Er du sikker på du vil udsende emails med godkendelse af planlagt dato til kunderne på denne kørselsplan?"
                                                                    OnClientCancel="CancelClick" />
                                                                <asp:LinkButton ID="lbtnCustomerConfirmed" runat="server" 
                                                                    OnClick="lbtnCustomerConfirmed_Click">Angiv kunde godkendelse</asp:LinkButton>
                                                                <asp:LinkButton ID="lbtnRemoveCustomerConfirmed" runat="server" 
                                                                    OnClick="lbtnRemoveCustomerConfirmed_Click">Fjern kunde godkendelse</asp:LinkButton>
                                                            </td>--%>
                                                        </tr>
                                                    </table>
                                                    <br />
                                                    <dxwgv:ASPxGridView ID="gvServiceCarScheduleDetail" runat="server" 
                                                        Caption="Planlagte hjulskift" 
                                                        ClientInstanceName="gvServiceCarScheduleDetail" Width="100%"
                                                        KeyFieldName="ServiceCarScheduleDetailId" AutoGenerateColumns="False" 
                                                        EnableCallBacks="False" OnRowDeleting="gvServiceCarScheduleDetail_RowDeleting"
                                                        oncustomunboundcolumndata="gvServiceCarScheduleDetail_CustomUnboundColumnData"
                                                        oncustombuttoncallback="gvServiceCarScheduleDetail_CustomButtonCallback" OnHtmlRowPrepared="gvServiceCarScheduleDetail_HtmlRowPrepared" 
                                                        OnFocusedRowChanged="gvServiceCarScheduleDetail_FocusedRowChanged">
                                                        <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                                                        <Border BorderWidth="0px" />
                                                        <Settings ShowFooter="true" ShowVerticalScrollBar="true" ShowHeaderFilterButton="False" ShowGroupPanel="false" ShowFilterRow="False" />
                                                        <SettingsText ConfirmDelete="Vil du slette dette planlagte hjulskift?" />
                                                        <SettingsPager Summary-Visible="true" AlwaysShowPager="False" PageSize="20" Position="Bottom">
                                                            <Summary 
                                                                AllPagesText="Sider: {0} - {1} ({2} hjulskift)" 
                                                                Text="Side {0} af {1} ({2} hjulskift)" />
                                                        </SettingsPager>
                                                        <SettingsBehavior ProcessFocusedRowChangedOnServer="true" AllowFocusedRow="true" ConfirmDelete="True" AllowGroup="true" AllowDragDrop="false" />
                                                        <Columns>
                                                            <dxwgv:GridViewCommandColumn VisibleIndex="1">
                                                                <DeleteButton Text="Slet" Visible="true" />
                                                                <CustomButtons>
                                                                    <%--<dxwgv:GridViewCommandColumnCustomButton Text="Tidspunkt" ID="UpdateTime" />--%>
                                                                    <dxwgv:GridViewCommandColumnCustomButton Text="Flyt op" ID="MoveUp" />
                                                                    <dxwgv:GridViewCommandColumnCustomButton Text="Flyt ned" ID="MoveDown" />
                                                                </CustomButtons>
                                                            </dxwgv:GridViewCommandColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ServiceCarScheduleDetailId" Visible="false" VisibleIndex="4" Caption="ServiceCarScheduleDetailId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ServiceCarScheduleId" Visible="false" VisibleIndex="4" Caption="ServiceCarScheduleId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="CarId" Visible="false" VisibleIndex="4" Caption="CarId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ServiceCarId" Visible="false" VisibleIndex="4" Caption="ServiceCarId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="EmployeeId" Visible="false" VisibleIndex="4" Caption="EmployeeId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ScheduleDate" Visible="false" VisibleIndex="4" Caption="ScheduleDate">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ContainerId" Visible="false" VisibleIndex="4" Caption="ContainerId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="FromTireSetId" Visible="false" VisibleIndex="4" Caption="FromTireSetId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ToTireSetId" Visible="false" VisibleIndex="4" Caption="ToTireSetId">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ToLongitude" Visible="false" VisibleIndex="4" Caption="ToLongitude">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ToLatitude" Visible="false" VisibleIndex="4" Caption="ToLatitude">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="CustomerConfirmed" Visible="false" VisibleIndex="4" Caption="CustomerConfirmed">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="SequenceNumber" VisibleIndex="5" Caption="Nr">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ToAddress" VisibleIndex="5" Caption="Adresse">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataColumn FieldName="ToCity" VisibleIndex="5" Caption="By">
                                                            </dxwgv:GridViewDataColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="StartTime" VisibleIndex="6" Caption="Start">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="EndTime" VisibleIndex="6" Caption="Slut">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="DrivingDistance" VisibleIndex="6" Caption="Km">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="EstimatedDrivingTime" VisibleIndex="6" Caption="Tid">
                                                            </dxwgv:GridViewDataTextColumn>
                                                            <dxwgv:GridViewDataTextColumn FieldName="EstimatedServiceTaskTime" UnboundType="String" VisibleIndex="6" Caption="Arb.tid">
                                                            </dxwgv:GridViewDataTextColumn>
                                                        </Columns>
                                                        <TotalSummary>
                                                            <dxwgv:ASPxSummaryItem Tag="Total kørsel" ShowInGroupFooterColumn="DrivingDistance" FieldName="DrivingDistance" SummaryType="Sum" DisplayFormat="N"/>
                                                            <dxwgv:ASPxSummaryItem Tag="Total kørseltid" ShowInGroupFooterColumn="EstimatedDrivingTime" FieldName="EstimatedDrivingTime" SummaryType="Sum" DisplayFormat="N"/>
                                                            <dxwgv:ASPxSummaryItem Tag="Total service tid" ShowInGroupFooterColumn="EstimatedServiceTaskTime" FieldName="EstimatedServiceTaskTime" SummaryType="Sum" DisplayFormat="N"/>
                                                        </TotalSummary>                                            
                                                    </dxwgv:ASPxGridView>

                                                </dx:SplitterContentControl>
                                            </ContentCollection>
                                        </dx:SplitterPane>
                                        <%--<dx:SplitterPane Name="spServiceTask" MinSize="100px" ShowCollapseForwardButton="True" Collapsed="true">
                                            <ContentCollection>
                                                <dx:SplitterContentControl ID="SplitterContentControl6" runat="server">
                                                    
                                                    Gridview 5: Service opgaver

                                                </dx:SplitterContentControl>
                                            </ContentCollection>
                                        </dx:SplitterPane>--%>
                                    </Panes>
                                    <ContentCollection>
                                        <dx:SplitterContentControl runat="server" SupportsDisabledAttribute="True">
                                        </dx:SplitterContentControl>
                                    </ContentCollection>
                                </dx:SplitterPane>
                                <%--<dx:SplitterPane Name="spDirectionMap" ShowCollapseForwardButton="True" Collapsed="true">
                                    <ContentCollection>
                                        <dx:SplitterContentControl ID="SplitterContentControl1" runat="server">
                                                    
                                            Googlemap med retning

                                        </dx:SplitterContentControl>
                                    </ContentCollection>
                                </dx:SplitterPane>--%>
                            </Panes>
                        </dx:ASPxSplitter>

                    </ContentTemplate>
                </asp:UpdatePanel>
                
            </dx:PanelContent>
        </PanelCollection>
        <HeaderTemplate>
            <table cellpadding="0" cellspacing="2" border="0">
                <tr>
                    <td>
                        <img id="imgServiceCarSchedule" alt="" src="~/Images/Medium/stopwatch.png" runat="server" style="width: 32px; height: 32px" />
                    </td>
                    <td valign="middle">
                        <h3><asp:Label ID="lblServiceCarScheduleHeader" runat="server" Text="Service planlægning"></asp:Label></h3>
                    </td>
                </tr>
            </table>
        </HeaderTemplate>
    </dx:ASPxRoundPanel>

</asp:Content>
